package com.puermobile;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;

public class AntennaCameraActivity extends Activity {
    /** Called when the activity is first created. */

	private Button m_bt_takepic_left, m_bt_takepic_mid, m_bt_takepic_right;
	private Button m_bt_takepic_east, m_bt_takepic_south, m_bt_takepic_west, m_bt_takepic_north;
	private ImageView m_iv_takepic_left, m_iv_takepic_mid, m_iv_takepic_right;
	private ImageView m_iv_takepic_east, m_iv_takepic_south, m_iv_takepic_west, m_iv_takepic_north;
	private Button m_bt_antenna_ok, m_bt_antenna_cancel;
	
	private boolean m_img_left, m_img_mid, m_img_right;
	private boolean m_img_east, m_img_south, m_img_west, m_img_north;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	Log.v("AntennaCameraActivity", "oncreate");
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN ,  
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.antenna_camera);
        
    	m_bt_takepic_left = (Button)findViewById(R.id.btn_antennacamera_left);
    	m_bt_takepic_mid = (Button)findViewById(R.id.btn_antennacamera_mid);
    	m_bt_takepic_right = (Button)findViewById(R.id.btn_antennacamera_right);
    	
    	m_bt_takepic_east = (Button)findViewById(R.id.btn_antennacamera_east);
    	m_bt_takepic_south = (Button)findViewById(R.id.btn_antennacamera_south);
    	m_bt_takepic_west = (Button)findViewById(R.id.btn_antennacamera_west);
    	m_bt_takepic_north = (Button)findViewById(R.id.btn_antennacamera_north);
    	
    	m_iv_takepic_left = (ImageView)findViewById(R.id.imgv_antennacamera_left);
    	m_iv_takepic_mid = (ImageView)findViewById(R.id.imgv_antennacamera_mid);
    	m_iv_takepic_right = (ImageView)findViewById(R.id.imgv_antennacamera_right);
    	
    	m_iv_takepic_east = (ImageView)findViewById(R.id.imgv_antennacamera_east);
    	m_iv_takepic_south = (ImageView)findViewById(R.id.imgv_antennacamera_south);
    	m_iv_takepic_west = (ImageView)findViewById(R.id.imgv_antennacamera_west);
    	m_iv_takepic_north = (ImageView)findViewById(R.id.imgv_antennacamera_north);
        
    	m_bt_antenna_ok = (Button)findViewById(R.id.btn_antennacamera_ok);
    	m_bt_antenna_cancel = (Button)findViewById(R.id.btn_antennacamera_cancel);
  
    	m_img_left = false;
        m_img_mid = false;
        m_img_right = false;
        
    	m_img_east = false;
        m_img_south = false;
        m_img_west = false;
        m_img_north = false;
        
        m_bt_takepic_left.setOnClickListener(new Button.OnClickListener()
		{
			public void onClick(View v)
			{
				Intent i = new Intent("android.media.action.IMAGE_CAPTURE");  
	 			startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER); 
	 			m_img_left = true;
			}
		});  
        
        m_bt_takepic_mid.setOnClickListener(new Button.OnClickListener()
		{
			public void onClick(View v)
			{
				Intent i = new Intent("android.media.action.IMAGE_CAPTURE");  
	 			startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER); 
	 			m_img_mid = true;
			}
		}); 
        
        m_bt_takepic_right.setOnClickListener(new Button.OnClickListener()
		{
			public void onClick(View v)
			{
				Intent i = new Intent("android.media.action.IMAGE_CAPTURE");  
	 			startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER); 
	 			m_img_right = true;
			}
		}); 
        
        m_bt_takepic_east.setOnClickListener(new Button.OnClickListener()
		{
			public void onClick(View v)
			{
				Intent i = new Intent("android.media.action.IMAGE_CAPTURE");  
	 			startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER); 
	 			m_img_east = true;
			}
		});  
        
        m_bt_takepic_south.setOnClickListener(new Button.OnClickListener()
		{
			public void onClick(View v)
			{
				Intent i = new Intent("android.media.action.IMAGE_CAPTURE");  
	 			startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER); 
	 			m_img_south = true;
			}
		}); 
        
        m_bt_takepic_west.setOnClickListener(new Button.OnClickListener()
		{
			public void onClick(View v)
			{
				Intent i = new Intent("android.media.action.IMAGE_CAPTURE");  
	 			startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER); 
	 			m_img_west = true;
			}
		}); 
       
        m_bt_takepic_north.setOnClickListener(new Button.OnClickListener()
		{
			public void onClick(View v)
			{
				Intent i = new Intent("android.media.action.IMAGE_CAPTURE");  
	 			startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER); 
	 			m_img_north = true;
			}
		}); 
        
        m_bt_antenna_ok.setOnClickListener(new Button.OnClickListener()
		{
			public void onClick(View v)
			{
				//Intent i = new Intent("android.media.action.IMAGE_CAPTURE");  
	 			//startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER); 
	 			finish();
			}
		});
        
        m_bt_antenna_cancel.setOnClickListener(new Button.OnClickListener()
		{
			public void onClick(View v)
			{
				//Intent i = new Intent("android.media.action.IMAGE_CAPTURE");  
	 			//startActivityForResult(i, Activity.DEFAULT_KEYS_DIALER);  
	 			finish();
			}
		});
    }
    
	@Override
	protected void onActivityResult(int requestCode, int resultCode,Intent data) 
	{
		Log.v("BsCameraActivity", "oncreate");
		switch(resultCode)
		{
		 case RESULT_OK:
		 	super.onActivityResult(requestCode, resultCode, data); 
			if(data!=null){
	    		Bundle extras = data.getExtras();  
	    		Bitmap bmp = (Bitmap) extras.get("data"); 
	    		if(m_img_left)
	    		{
	    			m_iv_takepic_left.setImageBitmap(bmp);
	    			m_img_left = false;
	    		}
	    		else if(m_img_mid)
	    		{
	    			m_iv_takepic_mid.setImageBitmap(bmp);
	    			m_img_mid = false;
	    		}
	    		else if(m_img_right)
	    		{
	    			m_iv_takepic_right.setImageBitmap(bmp);
	    			m_img_right = false;
	    		}
	    		else if(m_img_east)
	    		{
	    			m_iv_takepic_east.setImageBitmap(bmp);
	    			m_img_east = false;
	    		}
	    		else if(m_img_south)
	    		{
	    			m_iv_takepic_south.setImageBitmap(bmp);
	    			m_img_south = false;
	    		}
	    		else if(m_img_west)
	    		{
	    			m_iv_takepic_west.setImageBitmap(bmp);
	    			m_img_west = false;
	    		}
	    		else if(m_img_north)
	    		{
	    			m_iv_takepic_north.setImageBitmap(bmp);
	    			m_img_north = false;
	    		}
			}
			else
			{
				 //hasShootPic = false;
			}
		    break;
			default:
				break;
		}
		
	}
}